<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\DiscoverService;


class DiscoverController extends BaseController
{
    /**
     *    朋友圈列表
     *    hinq 2019 10 28
     *
     **/
    public function index()
    {
        $arr_search = (array)Request::all();
        $arr_list = DiscoverService::get_discover_list((array)$arr_search);
        echo_error($arr_list);
        return view('admin::discover.index', $arr_list['data']);
    }


    /**
     *  添加朋友圈
     *    hinq 2019 10 28
     *
     **/
    public function create()
    {
        return view('admin::discover.create');
    }


    /**
     *    添加朋友圈数据
     *    hinq 2019 10 28
     *
     **/
    public function store()
    {
        $arr_input = (array)Request::input();
        return DiscoverService::store((array)$arr_input);
    }

    /**
     *    删除朋友圈
     *    hinq 2019 10 28
     *
     **/
    public function del()
    {
        $nId = (int)Request::get('id');
        return DiscoverService::del((int)$nId);
    }


    /**
     *    朋友圈详细信息
     *    hinq 2019 10 29
     *
     **/
    public function detail()
    {
        $arr_search = Request::all();
        //获取数据
        $arr_list = DiscoverService::detail((array)$arr_search);
        echo_error($arr_list);
        return view('admin::discover.detail', $arr_list['data']);
    }

    /**
     *  编辑朋友圈信息
     *  hinq 2019 12 05
     *
     **/
    public function edit(Request $request)
    {
        $nId = $request::get('id');
        $arr_list = DiscoverService::get_one((int)$nId);
        return view('admin::discover.edit', ['info' => $arr_list['data']]);
    }

    /**
     *  编辑朋友圈信息
     *  hinq 2019 12 05
     *
     **/
    public function info(Request $request)
    {
        $nId = $request::get('id');
        $act = $request::get('act');
        $arr_list = DiscoverService::get_one((int)$nId);
        return view('admin::discover.edit', ['info' => $arr_list['data'] , 'act' => $act ] );
    }




    /**
     *  编辑朋友圈信息
     *  hinq 2019 12 05
     *
     **/
    public function update(Request $request)
    {
        $arr_input = (array)$request::all();
        return DiscoverService::update((array)$arr_input);
    }


    /**
     *  获取所有商户提交并未审核的图文列表
     *  hinq 2020 6 11
     *
     **/
    public function list( Request $request ){
        $arr_search = (array)$request::all();
        $arr_list = DiscoverService::get_list( (array) $arr_search );
        return view("admin::discover.list" , $arr_list['data']);
    }

    /**
     *  平台审核商户添加的朋友圈信息
     *  hinq 2020 6 11
     *
     **/
    public function shenhe( Request $request ){
        $arr_input = (array) $request::all();
        return DiscoverService::shenhe( (array) $arr_input );
    }


}